package com.baidu.project.chart2;

public class ShapeFactory {
    // 静态工厂方法
    public static Shape getShape(String type) {
        Shape shape = null;
        if (type.contentEquals("circle")) {
            shape = new Circle();
            System.out.println("初始化圆形");
        }else if (type.contentEquals("rectangle")) {
            shape = new Rectangle();
            System.out.println("初始化矩形");
        }else if (type.contentEquals("triangle")) {
            shape = new Triangle();
            System.out.println("初始化三角形");
        }
        return shape;
    }
}